﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;

namespace VisaCRM.Common.DataLayer
{
   public static class DataAccess
    {
        private static SqlConnection sqlConnection;

        /// <summary>
        /// Opening connection
        /// </summary>
        public static SqlConnection OpenConnection()
        {
            sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnstring"].ConnectionString);
            sqlConnection.Open();
            return sqlConnection;
        }

        /// <summary>
        /// Closing connection
        /// </summary>
        public static void CloseConnection()
        {
            if (sqlConnection.State == System.Data.ConnectionState.Open)
            {
                sqlConnection.Close();
            }
            sqlConnection.Dispose();
        }
    }
}
